package com.example.polardbxdemo.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName(value = "material", autoResultMap = true)
public class Material {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 物料名称
     */
    @TableField("name")
    private String name;

    /**
     * 物料编码
     */
    @TableField("code")
    private String code;

    /**
     * 物料类型
     */
    @TableField("type")
    private Integer type;

    /**
     * 价格
     */
    @TableField("price")
    private Double price;

    /**
     * 库存数量
     */
    @TableField("stock")
    private Integer stock;

    /**
     * 是否启用
     */
    @TableField("enabled")
    private Boolean enabled;

    /**
     * JSON类型字段 - 扩展属性
     * 使用TypeHandler处理JSON转换
     */
    @TableField(value = "properties", typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> properties;

    /**
     * JSON类型字段 - 规格参数
     */
    @TableField(value = "specifications", typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> specifications;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 逻辑删除字段
     */
    @TableField("deleted")
    @TableLogic
    private Integer deleted;
}